<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>修改资料</title>
		<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
		<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
		<script src="jquery.Jcrop.js"></script>
		<style>
		@font-face {
		  font-family: 'iconfont';  /* project id 416894 */
		  src: url('http://at.alicdn.com/t/font_416894_vy1ju04z9ofxbt9.eot');
		  src: url('http://at.alicdn.com/t/font_416894_vy1ju04z9ofxbt9.eot?#iefix') format('embedded-opentype'),
		  url('http://at.alicdn.com/t/font_416894_vy1ju04z9ofxbt9.woff') format('woff'),
		  url('http://at.alicdn.com/t/font_416894_vy1ju04z9ofxbt9.ttf') format('truetype'),
		  url('http://at.alicdn.com/t/font_416894_vy1ju04z9ofxbt9.svg#iconfont') format('svg');
}

		body{
				margin: 0;
				padding: 0;
				background-color: #f3f3f3;
			}
			
		.top{
				display: flex;
				width: 100%;
				height: 50px;
				background-color: white;
				position: fixed;
				top: 0;
				box-shadow: 0px 2px 5px #888888;
			}

		.logo{
			height: 40px;
			padding: 5px;
			padding-left: 200px;
		}
		
		.top_left{
			flex: 1;
		}
		
		.top_mid{
			flex: 1;
			font-family: "iconfont" !important;
			text-align: center;
			padding: 13px;
			padding-left: 15px;
		}
		
		.top_right{
			flex: 1;
			padding: 10px;
			padding-left: 80px;
		}
		
		.top_find{
			
			padding: 3px;
			
		}
		
		.top_img{
			width: 30px;
			height: 30px;
			background-color: blue;
		}
		
		.mid{
				margin-top: 60px;
				margin-left: auto;
				margin-right: auto;
				width: 75%;
			}
			
		.mid_left{
			/*padding: 3px;*/
			/*padding-right: 0px;*/
			float: left;
			width: 24%;
			background: white;
			height: 100%;
		}
		
		.mid_right{
			padding-left: 0px;
			padding: 3px;
			float: left;
			width: 65%;
			right: 13%;
			background: white;
			border-left: 1px solid #00aaff;
			min-height: 200px;
		}	
		.tab_item{
			text-align: center;
			padding: 4px;
			padding-top: 16px;
			padding-bottom: 16px;
			cursor: pointer;
		}

		.tab_item_selected{
			border-right: 4px solid #00aaff;
			background: #cceeff;
			padding-right: 0px;
		}

		.tab_item:hover{
			background: #cceeff;
		}

		.alertArea{
			height: 64px;
		}

		#img_alter_page{
			display: flex;
		}
		.img_alter_left{
			padding: 16px;
		}
		.img_alter_right{
			flex: 1;
			padding: 16px;
		}
		#head_img_origin{
			width: 100px;
			height: 100px;
			background: #000;
		}
		#cropArea{
			background: #ccc;
			/*min-width: 80%;*/
			width: 100%;
			min-height: 300px;
			display:inline-block; 
			*display:inline; 
			*zoom:1;

			cursor: pointer;
		}
		#change_head_btn{
			height: 300px;
		    width: 100px;
		    margin: auto;
		    text-align: center;
		    padding-top: 140px;
		    font-family: "iconfont" !important;
		}
		#cropImg{
			margin-left: auto;
			margin-right: auto;
		}
		.jcrop-holder{
			margin-left: auto;
			margin-right: auto;
		}
		</style>
	</head>
	<body>
	<!-- <div class="top" >
		<div class="top_left">
			<img class="logo" src="img/logo.png" />
		</div>
		<div class="top_mid">
			<input class="top_find" type="text" />
			<span class="search_btn">&#xe6a7;</span>
		</div>
		<div class="top_right">
			<img class="top_img" src="img/back.png" />
		</div>
	</div> -->
	<div id="nav_area"></div>
	
	<div class="mid">
		<div class="mid_left">
			<div id="data_alter" class="tab_item tab_item_selected">修改资料</div>
			<div id="img_alter" class="tab_item">头像修改</div>
			<div id="pass_alter" class="tab_item">密码修改</div>
		</div>
		
		<div class="mid_right">
			<div id="data_alter_page">
				<br>
				<div class="alertArea" id="alertAreaData"></div>
				
				<div class="form-group" id="nicknameFormgroup">
					<label for="nicknameInput" class="col-sm-2 control-label">昵称 <span style="color: red;">*</span></label>
					<div class="col-sm-10">
						<input type="text" class="form-control" id="nicknameInput" placeholder="昵称">
						<label class="help-block" id="nicknameMsg"></label>
					</div>
				</div>
				<br><br>
				<div class="form-group">
					<label for="inputEmail3" class="col-sm-2 control-label">地区</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" id="areaInput" placeholder="地区">
					</div>
				</div>
				<br><br>
				<div class="form-group">
					<label for="inputEmail3" class="col-sm-2 control-label">性别</label>
					<div class="col-sm-10" id="sexRadio">
						<label class="radio-inline">
							<input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="0" checked="checked"> 保密
						</label>
						<label class="radio-inline">
							<input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="1"> 男
						</label>
						<label class="radio-inline">
							<input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="2"> 女
						</label>
					</div>
				</div>
				<br><br>
				<div class="form-group">
					<label for="inputEmail3" class="col-sm-2 control-label">生日</label>
					<div class="col-sm-10">
						<input type="date" class="form-control" id="birthdayInput" placeholder="生日">
					</div>
				</div>
				<br><br>
				<div class="form-group">
					<label for="inputEmail3" class="col-sm-2 control-label">个性签名</label>
					<div class="col-sm-10">
						<textarea class="form-control" rows="3" placeholder="个性签名" style="resize: none;" id="signtureInput"></textarea>
						<label class="help-block" id="nicknameMsg">还能输入<span id="word_counter">50</span>字</label>
					</div>
				</div>
				<br><br><br><br>
				<div style="text-align: center;">
					<button type="button" class="btn btn-primary" id="submitBtn" disabled="disabled">完成修改</button>
				</div>
				<br>

			</div>
			
			<div id="img_alter_page">
				<div class="img_alter_left">
					<img id="head_img_origin" src="">
				</div>
				<div class="img_alter_right">

					<div id="cropArea">
						<div id="change_head_btn">&#xe623; 更改头像</div>
						<div id="imgArea"></div>
						<!-- <img id="cropImg" style="display: none;"> -->
					</div>
					<input type="file" id="head_img_input" name="head_img" style="display:none" onchange="imgchange()" /> 
					<canvas id="myCan" width="100" height="100" style="display: none;"></canvas>
					<div style="text-align: center; margin-top: 16px;">
						<button type="button" class="btn btn-default" id="replaceHeadBtn" style="display: none;">更改图片</button>
						<button type="button" class="btn btn-primary" id="submitHeadBtn" disabled="disabled">完成修改</button>
					</div>
				</div>
			</div>
			<div id="pass_alter_page">
				<br>
				<div class="alertArea" id="alertAreaPass"></div>
				
				<div class="form-group" id="oldPassFormGroup">
					<label for="oldPassInput" class="col-sm-2 control-label">原密码 <span style="color: red;">*</span></label>
					<div class="col-sm-10">
						<input type="password" class="form-control" id="oldPassInput" placeholder="原密码">
						<label class="help-block" id="oldPassMsg"></label>
					</div>
				</div>
				<br><br>
				<div class="form-group" id="newPassFormGroup">
					<label for="newPassInput" class="col-sm-2 control-label">新密码 <span style="color: red;">*</span></label>
					<div class="col-sm-10">
						<input type="password" class="form-control" id="newPassInput" placeholder="新密码">
						<label class="help-block" id="newPassMsg"></label>
					</div>
				</div>
				<br><br>
				<div class="form-group" id="againPassFormGroup">
					<label for="againPassInput" class="col-sm-2 control-label">再次新密码 <span style="color: red;">*</span></label>
					<div class="col-sm-10">
						<input type="password" class="form-control" id="againPassInput" placeholder="再次密码">
						<label class="help-block" id="againPassMsg"></label>
					</div>
				</div>
				<br><br>
				<div style="text-align: center;">
					<button type="button" class="btn btn-primary" id="submitPassBtn">完成修改</button>
				</div>
				<br>


			</div>
		</div>
		
	</div>

<script src="nav.js"></script>
<script>

var currentTab = -1;
var nameValid = true;
var savedName = "";
var inputedSignature = "";

function showSex(sex){
	$("#inlineRadio1").removeAttr("checked");
	$("#inlineRadio2").removeAttr("checked");
	$("#inlineRadio3").removeAttr("checked");

	$("#inlineRadio" + (sex+1)).attr("checked", "checked");
}

function loadUserInfo(){
	$.get('userinfo.do', function(data){
		try{

			var jsonObj = JSON.parse(data);
			console.log(jsonObj);
			if (jsonObj.error == 0) {
				$("#nicknameInput").val(jsonObj.data.nickname);
				savedName = jsonObj.data.nickname;
				$("#areaInput").val(jsonObj.data.area);
				$("#birthdayInput").val(jsonObj.data.birthday);
				$("#signtureInput").val(jsonObj.data.signature);
				inputedSignature = jsonObj.data.signature;
				$("#word_counter").text(50 - getBLen($("#signtureInput").val()));

				var sex = parseInt(jsonObj.data.sex);
				showSex(sex);
			}else if (jsonObj.error == 220){
				// 用户未登录，跳到登陆页面
				window.location.href = "login.html";
			}else{
				showDataPostError();
				$(".mid_left").css("height", $(".mid_right").outerHeight());
			}
			
		}catch(ex){
			showDataPostError();
			$(".mid_left").css("height", $(".mid_right").outerHeight());
			console.log(ex);

		}
	})
}

function loadHeadImage(){
	$.get('userinfo.do', function(data){
		try{
			var jsonObj = JSON.parse(data);
			if (jsonObj.error == 0) {
				$("#head_img_origin").attr("src", 'img/head/'+jsonObj.data.head_image+'.jpg');
			}else if (jsonObj.error == 220) {
				window.location.href = "login.html";
			}
		}catch(ex){	
			alert("系统异常，请稍后重试");	
			// showDataPostError();
			// $(".mid_left").css("height", $(".mid_right").outerHeight());
			console.log(ex);
		}
	})
}

function switchTab(tab){
	$(".mid_left").children().removeClass("tab_item_selected");
	$(".mid_right").children().hide();

	switch(tab){
		case 0:
			$("#data_alter").addClass("tab_item_selected");
			$("#data_alter_page").show();
			if (currentTab != 0) {
				loadUserInfo();
			}
			break;
		case 1:
			$("#img_alter").addClass("tab_item_selected");
			$("#img_alter_page").show();
			if (currentTab != 1) {
				// $("#head_img_origin").attr("src", $(".nav_head_img").attr("src"));
				loadHeadImage();
			}
			break;
		case 2:
			$("#pass_alter").addClass("tab_item_selected");
			$("#pass_alter_page").show();
			break;
		default:
			break;
	}
	currentTab = tab;
	$(".mid_left").css("height", $(".mid_right").outerHeight());
}

function getQueryString(name){
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
}

$(document).ready(function(){

	showNavBar();
	var tab = getQueryString("t");
	// console.log(tab);
	if (tab != null) {
		try{
			var tabIndex = parseInt(tab);

			switchTab(tabIndex);
		}catch(ex){
			console.log(ex);
			switchTab(0);
		}
	}else{
		switchTab(0);
	}

})

$("#data_alter").click(function(){
	switchTab(0)
})
$("#img_alter").click(function(){
	switchTab(1)
})
$("#pass_alter").click(function(){
	switchTab(2)
})

function setNameError(err){
	$("#nicknameFormgroup").removeClass("has-success");
	if (err != '') {
		$("#nicknameFormgroup").addClass("has-error");
	}else{
		$("#nicknameFormgroup").removeClass("has-error");
	}
	
	$("#nicknameMsg").text(err);
	$(".mid_left").css("height", $(".mid_right").outerHeight());
}

function setNameSuccess(){
	$("#nicknameFormgroup").removeClass("has-error");
	$("#nicknameFormgroup").addClass("has-success");
	$("#nicknameMsg").text('昵称可以使用');
	$(".mid_left").css("height", $(".mid_right").outerHeight());
}

function checkName(){
	var nickname = $("#nicknameInput").val();

	if (nickname.length	== 0) {
		nameValid = false;
		setNameError('请输入昵称');
		return false;
	}
	var reg = /^([\u4e00-\u9fa5]|[a-z]|[A-Z]|[0-9]|-|_)+$/;
	var regex = new RegExp(reg);
	if (!regex.test(nickname)) {
		nameValid = false;
		setNameError('昵称支持中文, 字母, 数字, -和_');
		return false;
	}

	$.post('CheckName.do',{
		nickname: nickname
	}, function(data){
		try{
			var result = JSON.parse(data);
			if (result.error == 0) {
				nameValid = true;
				setNameSuccess();
				return true;
			}else{
				nameValid = false;
				setNameError('昵称已被占用');
				return false;
			}
		}catch(ex){
			nameValid = false;
			setNameError('出错，无法检查用户名');
			return false;
		}
		
	})
}

$("#nicknameInput").blur(function(){
	if (savedName != $("#nicknameInput").val()) {
		checkName();
	}else{
		setNameError('');
	}
	
})

// 编辑开始时，提交按钮可以点击
$("#data_alter_page").find("input").bind('input propertychange', function(){
	$("#submitBtn").removeAttr("disabled");
})
$("#data_alter_page").find("input").change(function(){
	$("#submitBtn").removeAttr("disabled");
})

function getBLen(str) {  
    if (str == null) return 0;  
    if (typeof str != "string"){  
        str += "";  
    }  
    return str.replace(/[^\x00-\xff]/g,"01").length;  
} 

$("#signtureInput").bind('input propertychange', function(){
	$("#submitBtn").removeAttr("disabled");

	// 计算个性签名字数
	var signature = $("#signtureInput").val();
	var wordCount = getBLen(signature);
	if (wordCount > 50) {
		$("#signtureInput").val(inputedSignature);
	}else{
		inputedSignature = signature;
	}
	$("#word_counter").text(50 - getBLen($("#signtureInput").val()));
})

function showDataPostError(){
	$("#alertAreaData").html('<div class="alert alert-danger alert-dismissible" role="alert">'+
						'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+
						'<strong>系统异常，请稍后重试!</strong>'+
					'</div>');
}

function showPassPostError(){
	$("#alertAreaPass").html('<div class="alert alert-danger alert-dismissible" role="alert">'+
						'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+
						'<strong>系统异常，请稍后重试!</strong>'+
					'</div>');
}


$("#submitBtn").click(function(){
	$("#submitBtn").attr("disabled", "disabled");

	// 检查昵称是否可以用
	if (!nameValid) {
		if (!checkName()) {
			return;
		}
	}else{
		//setNameSuccess();
		setNameError('');
	}
	var nickname = $("#nicknameInput").val();
	if (savedName == nickname) {
		nickname = "";
	}

	var area = $("#areaInput").val();
	var sex = $("#sexRadio").find("input:radio:checked").val();
	var birthday = $("#birthdayInput").val();
	var signature = $("#signtureInput").val();

	var postData = {
		nickname: nickname,
		area: area,
		sex: sex,
		birthday: birthday,
		signature: signature
	};

	$.post('userSetInfo.do', postData, function(data){
		console.log(data);
		try{
			var error = JSON.parse(data).error;
			if (error == 0) {
				if (savedName != nickname && nickname != "") {
					savedName = nickname;
					$("#nav_nickname").html(savedName);
				}
				$("#alertAreaData").html('<div class="alert alert-success alert-dismissible" role="alert">'+
						'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+
						'<strong>资料已修改!</strong>'+
					'</div>');
				// $(".mid_left").css("height", $(".mid_right").outerHeight());

			}else if (error == 220){
				// 用户未登录，跳到登陆页面
				window.location.href = "login.html";
			}else{
				showDataPostError();
				// $(".mid_left").css("height", $(".mid_right").outerHeight());
			}

		}catch(ex){
			showDataPostError();
			// $(".mid_left").css("height", $(".mid_right").outerHeight());
			console.log(ex);
		}
	})
})

function setOldPassError(err){
	if (err.length == 0) {
		$("#oldPassFormGroup").removeClass("has-error");
	}else{
		$("#oldPassFormGroup").addClass("has-error");
	}
	$("#oldPassMsg").text(err);
	$(".mid_left").css("height", $(".mid_right").outerHeight());
}

function setNewPassError(err){
	if (err.length == 0) {
		$("#newPassFormGroup").removeClass("has-error");
	}else{
		$("#newPassFormGroup").addClass("has-error");
	}
	$("#newPassMsg").text(err);
	$(".mid_left").css("height", $(".mid_right").outerHeight());
}

function setAgainPassError(err){
	if (err.length == 0) {
		$("#againPassFormGroup").removeClass("has-error");
	}else{
		$("#againPassFormGroup").addClass("has-error");
	}
	$("#againPassMsg").text(err);
	$(".mid_left").css("height", $(".mid_right").outerHeight());
}


$("#submitPassBtn").click(function(){
	var oldPass = $("#oldPassInput").val();
	var newPass = $("#newPassInput").val();
	var againPass = $("#againPassInput").val();

	if (oldPass.length == 0) {
		setOldPassError('请输入密码');
		return;
	}else{
		setOldPassError('');
	}

	if (newPass.length == 0) {
		setNewPassError('请输入新密码');
		return;
	}else{
		setNewPassError('');
	}


	if (againPass.length == 0) {
		setAgainPassError('请再次输入密码');
		return;
	}else{
		setAgainPassError('');
	}

	if (newPass.length < 6) {
		setNewPassError('请输入6位以上的密码');
		return;
	}else{
		setNewPassError('');
	}
	if (newPass != againPass) {
		setAgainPassError('两次密码不一致');
		return;
	}else{
		setAgainPassError('');
	}

	$("#submitPassBtn").attr("disabled", "disabled");
	$.post('changePassword.do', {
		old_pass: oldPass,
		new_pass: newPass,
		new_pass_again: againPass
	}, function(data){
		try{
			var error = JSON.parse(data).error;
			if (error == 0) {
				$("#alertAreaPass").html('<div class="alert alert-success alert-dismissible" role="alert">'+
						'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+
						'<strong>密码已修改!</strong>'+
					'</div>');
				// $(".mid_left").css("height", $(".mid_right").outerHeight());
				$("#oldPassInput").val('');
				$("#newPassInput").val('');
				$("#againPassInput").val('');
			}else if (error == 102){
				// 用户未登录，跳到登陆页面
				setOldPassError('密码不正确');
			}else if (error == 220){
				// 用户未登录，跳到登陆页面
				window.location.href = "login.html";
			}else{
				showPassPostError();
				// $(".mid_left").css("height", $(".mid_right").outerHeight());
			}
		}catch(ex){
			showPassPostError();
			console.log(ex)
		}
		$("#submitPassBtn").removeAttr("disabled");
	})

})

var cropImgLoaded = false;

$("#cropArea").click(function(){
	if (!cropImgLoaded) {
		$("#head_img_input").click();
	}
	
})

function imgchange() {  
  
    var localimg = $("#head_img_input").get(0).files[0];  

    if(!localimg){  
        return;  
    }  

    var fileName = localimg.name;  
    var fileSize = localimg.size;  
    var fileType=fileName.substring(fileName.lastIndexOf('.'),fileName.length).toLowerCase();  
    if(fileType!='.gif' && fileType!='.jpeg' && fileType!='.png' && fileType!='.jpg')  
    {  
        alert("上传失败，请上传jpg,png格式的图片");  
        return;  
    }  

    var size=3*1024*1024;  
    if(fileSize>size){  
        alert("上传失败，请上传3MB以内的图片。");  
        return;  
    }  

    var reader=new FileReader();  
    //将文件读取为DataURL  
    reader.readAsDataURL(localimg);  
    reader.onload= function (e) {  
        // var localimghtml = '<img id="cropbox" src="' +  e.target.result + '" >';  
        // $("#imgfield").html(localimghtml);  
        cropImgLoaded = true;
        $(".jcrop-holder").remove();
        $("#cropImg").remove();
        $("#imgArea").html('<img id="cropImg" src="'+e.target.result+'">');
        // $("#cropImg").attr("src", e.target.result);
        $(".mid_left").css("height", $(".mid_right").outerHeight());
        // $("#cropImg").show();
        $("#change_head_btn").hide();
        // $("#replaceHeadBtn").show();
        // $("#cropArea").css("cursor", "");
        $("#submitHeadBtn").removeAttr("disabled");
        initJcrop();  
    };  

}

function initJcrop(){  
    $('#cropImg').Jcrop({  
        onSelect: updateCoords,  
        aspectRatio: 1,  
        boxWidth: 300,  
        boxHeight: 300  
    }, function () {  

        //图片实际尺寸  
        var bb = this.getBounds();  
        var bWidth= Number(bb[0]) / 2;  
        var bHeight= Number(bb[1]) / 2;  

        this.setSelect([0, 0, bWidth,bHeight]);  


        var ss = this.getWidgetSize();  
        var aheight = (300 - Number(ss[1])) / 2 + "px";  
        $(".jcrop-holder").css("margin-top", aheight);  


    });  
}
function updateCoords(c){  
//      console.log(c);  
    var img=document.getElementById("cropImg");  
    var ctx=document.getElementById("myCan").getContext("2d");  

    //img,开始剪切的x,Y坐标宽高，放置图像的x,y坐标宽高。  
    ctx.drawImage(img,c.x,c.y, c.w, c.h,0,0,100,100);  
} 

//**dataURL to blob**  
function dataURLtoBlob(dataurl) {  
    var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],  
            bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);  
    while (n--) {  
        u8arr[n] = bstr.charCodeAt(n);  
    }  
    return new Blob([u8arr], { type: mime });  
} 

$("#submitHeadBtn").click(function(){
	//获取裁剪完后的base64图片url,转换为blob  
    var data=document.getElementById("myCan").toDataURL();  
    var formData=new FormData();  
    formData.append("imageName",dataURLtoBlob(data));  

    $.ajax({
    	url: 'changeHead.do',
    	type: 'POST',
    	contentType: false,
    	processData: false,
    	cache: false,
    	data: formData,
    	success: function(data){
    		try{
	    		var jsonObj = JSON.parse(data);
	    		if (jsonObj.error == 0) {
	    			cropImgLoaded = false;
			        // $("#cropImg").attr("src", e.target.result);
			        // $("#cropImg").hide();
			        $(".jcrop-holder").remove();
			        $("#cropImg").remove();

			        var fileInput = $("#head_img_input");
			        fileInput.after(fileInput.clone().val(''));
			        fileInput.remove();

			        $("#replaceHeadBtn").hide();
			        $("#change_head_btn").show();
			        $(".mid_left").css("height", $(".mid_right").outerHeight());
			        // $("#cropArea").css("cursor", "");
			        $("#submitHeadBtn").attr("disabled", "disabled");

			        $("#head_img_origin").attr("src", 'img/head/'+jsonObj.data+'.jpg');
			        $("#nav_head_img").attr("src", 'img/head/'+jsonObj.data+'.jpg');

	    		}else if (jsonObj.error == 220) {
	    			window.location.href = "login.html";
	    		}else{
	    			alert("系统异常，请稍后重试");
	    		}
	    	}catch(ex){
	    		alert("系统异常，请稍后重试");
	    	}
    	}
    })

    // $.post('testUpload.do', formData, function(data){
    // 	try{
    // 		var jsonObj = JSON.parse(data);
    // 		if (jsonObj.error == 0) {
    // 			cropImgLoaded = false;
		  //       // $("#cropImg").attr("src", e.target.result);
		  //       $("#cropImg").hide();
		  //       $("#change_head_btn").show();
		  //       $(".mid_left").css("height", $(".mid_right").outerHeight());
		  //       // $("#cropArea").css("cursor", "");
		  //       $("#submitHeadBtn").attr("disabled", "disabled");

    // 		}
    // 	}catch(ex){
    // 		alert("系统异常，请稍后重试");
    // 	}
    // })


})

$("#replaceHeadBtn").click(function(){
	$("#head_img_input").click();
})

</script>
	</body>
</html>
